package com.link.base.base.invtxn.service;

import com.link.base.base.invtxn.dao.mybatis.mapper.InvtxnMapper;
import com.link.base.base.invtxn.model.Invtxn;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.model.CallParam;
import com.link.core.basic.service.ServiceException;
import com.link.core.basic.service.BasicServiceImpl;
import com.link.core.util.StringUtils;
import com.link.core.util.UserUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author unknown
 * @date unknown
 * @desc 交易信息处理
 */
@Service("invtxnService")
public class InvtxnServiceImpl extends BasicServiceImpl<Invtxn> implements InvtxnService {

    @Resource
    private InvtxnMapper invtxnMapper;

    @Override
    public BasicMapper<Invtxn> getBasicMapper() {
        return invtxnMapper;
    }

    @Override
    public void goodConfirm(Long id) throws Exception {
        if (null == id) {
            throw new ServiceException("PUBLIC-007");
        }
        CallParam callParam = new CallParam();
        callParam.setParam1(id);
        callParam.setParam2(String.valueOf(UserUtil.getUser().getId()));
        invtxnMapper.calGoodConfirm(callParam);
        String ok = "OK";
        if (!StringUtils.equals(ok, callParam.getReturnStatus())) {
            throw new ServiceException(callParam.getMsgData());
        }
    }
}


